<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>授课 - PPT管理 - 析码无界</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
        }
        .navbar {
            border-radius: 0;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
        .navbar-brand {
            color: white !important;
            font-weight: bold;
        }
        .navbar-nav > li > a {
            color: rgba(255,255,255,0.9) !important;
        }
        .navbar-nav > li > a:hover {
            color: white !important;
            background-color: rgba(255,255,255,0.1) !important;
        }
        .navbar-nav > .active > a {
            background-color: rgba(255,255,255,0.2) !important;
            color: white !important;
        }
        .main-content {
            margin-top: 20px;
        }
        .panel {
            border: none;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            border-radius: 8px;
        }
        .panel-heading {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 8px 8px 0 0;
        }
        .btn-primary {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
        .btn-primary:hover {
            background: linear-gradient(90deg, #5568d3 0%, #653a91 100%);
        }
        .avatar-container {
            display: inline-block;
            margin-right: 10px;
            vertical-align: middle;
        }
        .teacher-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 2px solid rgba(255,255,255,0.8);
            object-fit: cover;
            cursor: pointer;
            transition: transform 0.2s;
        }
        .teacher-avatar:hover {
            transform: scale(1.1);
        }
        .navbar-brand {
            display: flex;
            align-items: center;
        }
        .ppt-item {
            padding: 15px;
            border-bottom: 1px solid #eee;
            transition: background-color 0.3s;
        }
        .ppt-item:hover {
            background-color: #f8f9fa;
        }
        .ppt-item:last-child {
            border-bottom: none;
        }
        .upload-area {
            border: 2px dashed #667eea;
            border-radius: 8px;
            padding: 30px;
            text-align: center;
            background-color: #f8f9fa;
            margin-bottom: 20px;
        }
        .upload-area:hover {
            background-color: #f0f0f0;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" th:href="@{/teacher}" style="display: flex; align-items: center;">
                    <div class="avatar-container">
                        <img th:src="${session.teacher?.avatar != null and !session.teacher.avatar.isEmpty() ? '/' + session.teacher.avatar : ''}" 
                             class="teacher-avatar"
                             th:onclick="'location.href=\'' + @{/teacher/settings} + '\''"
                             onerror="if(this.src.indexOf('data:image') === -1) { this.onerror=null; this.src=''; }"
                             alt="头像">
                    </div>
                    <span><i class="fa fa-graduation-cap"></i> 析码无界 - 教师管理平台</span>
                </a>
            </div>
            <ul class="nav navbar-nav">
                <li><a th:href="@{/teacher/profile}">个人信息</a></li>
                <li><a th:href="@{/teacher/settings}"><i class="fa fa-cog"></i> 设置</a></li>
                <li class="active"><a th:href="@{/ppt/list}"><i class="fa fa-file-powerpoint-o"></i> 授课</a></li>
                <li><a th:href="@{/assignment/list}">作业管理</a></li>
                <li><a th:href="@{/class/list}">班级管理</a></li>
                <li><a th:href="@{/teacher/student/list}"><i class="fa fa-list"></i> 学生列表</a></li>
                <li><a th:href="@{/teacher/student/add}"><i class="fa fa-plus"></i> 添加学生</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/"><i class="fa fa-sign-out"></i> 退出登录</a></li>
            </ul>
        </div>
    </nav>

    <div class="container main-content">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-file-powerpoint-o"></i> 授课 - PPT管理</h3>
            </div>
            <div class="panel-body">
                <div th:if="${message}" class="alert alert-success" th:text="${message}"></div>
                <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>
                
                <!-- 上传PPT区域 -->
                <div class="upload-area">
                    <h4><i class="fa fa-cloud-upload"></i> 上传PPT</h4>
                    <p class="text-muted">支持 .ppt 和 .pptx 格式</p>
                    <form th:action="@{/ppt/upload}" method="post" enctype="multipart/form-data" id="uploadForm">
                        <div class="form-group" style="max-width: 400px; margin: 0 auto;">
                            <input type="file" name="file" id="fileInput" accept=".ppt,.pptx" required 
                                   style="display: none;" onchange="document.getElementById('uploadForm').submit()">
                            <button type="button" class="btn btn-primary btn-lg" onclick="document.getElementById('fileInput').click()">
                                <i class="fa fa-folder-open"></i> 选择PPT文件
                            </button>
                        </div>
                        <div class="form-group" style="max-width: 400px; margin: 15px auto 0;">
                            <input type="text" name="pptName" class="form-control" placeholder="PPT名称（可选，默认使用文件名）">
                        </div>
                        <div class="form-group" style="max-width: 400px; margin: 10px auto 0;">
                            <textarea name="description" class="form-control" rows="2" placeholder="PPT描述（可选）"></textarea>
                        </div>
                    </form>
                </div>
                
                <!-- PPT列表 -->
                <div th:if="${ppts != null and !ppts.isEmpty()}" style="margin-top: 30px;">
                    <h4 style="margin-bottom: 20px;"><i class="fa fa-list"></i> 我的PPT列表</h4>
                    <div class="panel panel-default">
                        <div class="panel-body" style="padding: 0;">
                            <div th:each="ppt : ${ppts}" class="ppt-item">
                                <div class="row">
                                    <div class="col-md-8">
                                        <h5 style="margin-top: 0; margin-bottom: 5px;">
                                            <i class="fa fa-file-powerpoint-o" style="color: #ff6b6b;"></i>
                                            <span th:text="${ppt.pptName}"></span>
                                        </h5>
                                        <p class="text-muted" style="margin-bottom: 5px;" th:if="${ppt.description != null and !ppt.description.isEmpty()}">
                                            <small th:text="${ppt.description}"></small>
                                        </p>
                                        <p class="text-muted" style="margin-bottom: 0;">
                                            <small>
                                                <i class="fa fa-file"></i> <span th:text="${ppt.fileName}"></span> |
                                                <i class="fa fa-clock-o"></i> 
                                                <span th:if="${ppt.uploadTime != null}" th:text="${#dates.format(ppt.uploadTime, 'yyyy-MM-dd HH:mm')}"></span>
                                                <span th:if="${ppt.uploadTime == null}">-</span>
                                                <span th:if="${ppt.fileSize != null and ppt.fileSize > 0}">
                                                    | <i class="fa fa-hdd-o"></i> 
                                                    <span th:text="${(ppt.fileSize / 1024.0)}"></span> KB
                                                </span>
                                            </small>
                                        </p>
                                    </div>
                                    <div class="col-md-4 text-right">
                                        <a th:href="@{/ppt/view(pptId=${ppt.id})}"
                                           target="_blank"
                                           class="btn btn-info btn-sm"
                                           title="在线预览PPT">
                                            <i class="fa fa-eye"></i> 预览
                                        </a>
                                        <a th:href="@{/ppt/download(pptId=${ppt.id})}"
                                           class="btn btn-primary btn-sm"
                                           title="下载PPT">
                                            <i class="fa fa-download"></i> 下载
                                        </a>
                                        <a th:href="@{/ppt/delete(pptId=${ppt.id})}"
                                           class="btn btn-danger btn-sm"
                                           title="删除PPT"
                                           th:data-ppt-name="${ppt.pptName}"
                                           onclick="return confirm('确定要删除PPT【' + this.getAttribute('data-ppt-name') + '】吗？删除后将无法恢复！');">
                                            <i class="fa fa-trash"></i> 删除
                                        </a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div th:if="${ppts == null or ppts.isEmpty()}" class="alert alert-info">
                    <i class="fa fa-info-circle"></i> 您还没有上传任何PPT，请点击上方"选择PPT文件"按钮上传。
                </div>
            </div>
        </div>
    </div>
</body>
</html>

